<template>
<div>
  <van-nav-bar
      title=""
      left-text="Return"
      left-arrow
      @click-left="tzback()"
  />
  <h1>支付宝支付</h1>
  <h2>订单名称：{{baths.name}}洗浴服务</h2>
  <h2>金额：{{baths.price}} 元</h2>
  <div><van-button @click="sendPay()">确认支付</van-button></div>
</div>
</template>

<script>
import {Toast} from "vant";

export default {
  name: "Payz",
  data(){
    return{
     baths:{

     }
    }
  },
  methods:{
    sendPay(){
      //发起创建支付请求
      var obj={
        money: this.baths.price,
        oid: this.baths.mid,
        title: this.baths.name+"洗浴服务",
      }
      this.axios.post("http://localhost:8081/api/payz/create.do",obj).then(res=>{
        if(res.data.code==200){
          //成功
          document.write("'"+res.data.data+"'");
        }else{

        }
      })
    },
    tzback(){
      var mid=this.$route.query.mid;
      this.$router.push({path:"/bathDetail",query:{mid:mid}});
    },
  },
  mounted() {
    //页面加载，就会执行

    //axios请求后端接口 查询详情
    //获取store的id
    var id=this.$route.query.mid;

    this.axios.get("http://localhost:8081/api/zancang/detail.do?id="+id).then(res=>{
      if(res.data.code==200){
        //成功
        this.baths=res.data.data;
        console.log(this.baths)
      }else{
        //失败
        Toast('亲，网络异常！');
      }
    })

  }
}
</script>

<style scoped>

</style>